﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SWENAssignment.ThinHui
{
    public partial class createStaffProfile1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string s_staffId = tbxStaffID.Text;
            staffDetails s = DBmanager.getByStaffId(s_staffId);
            if (s.StaffId == s_staffId)
            {
                lblcheckStaffId.Text = "Staff ID Already Exist. Please Change to Another One!";
            }
            else
            {
                string s_LastName = tbxLastName.Text;
                string s_FirstName = tbxFirstName.Text;
                string s_NRIC = tbxNRIC.Text;
                DateTime s_DOB = Convert.ToDateTime(ddlDate.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + tbxYear.Text);
                int s_contactNumber = Convert.ToInt32(tbxContactNo.Text);
                string s_Address = tbxAddress.Text;
                string s_Email = tbxEmail.Text;
                string s_Gender = rblGender.SelectedValue;
                string s_BankAccType = ddlBankAccType.SelectedValue;
                string s_BankAccNumber = tbxBankAccNumber.Text;
                string s_DutyType = ddlDutyType.SelectedValue;

                staffDetails newStaff = new staffDetails(s_staffId, s_FirstName, s_LastName, s_DutyType, s_DOB, s_contactNumber, s_Address, s_Email, s_Gender, s_NRIC, s_BankAccType, s_BankAccNumber);
                if (DBmanager.createStaffProfile(newStaff) == 1)
                {
                    Session["staffId"] = s_staffId;
                    //need to change
                    Server.Transfer("createStaffProfileSuccessfully.aspx?");
                }

                else
                {
                    lblStatus.Text = "Create is Unsuccessful";
                }
            }
        }
    }
}
   